/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package experimental.com.rhythm.commons.validation.bean;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

/**
 *
 * @author Michael J. Lee
 */
public abstract class ConstraintValidator<T extends Annotation> {

    public T instance;

    public ConstraintValidator() {
        //Must have a public no arg constructor!
    }

    public void initialize(T constraint) {
        instance = constraint;
    };

    public final T getInstance(){
        return instance;
    }

    protected final boolean isNull(Object value){
        return (value == null);
    }

    protected final boolean isString(Object value){
        return (value instanceof String);
    }

    protected final void fail(String message){
        throw new ConstraintVolationException(message);
    }

    public abstract void checkConstraint(Object value);
}
